/**
*      author: Y_Yao
*      created: 2025-03-22 19:10:27
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 7;
int n;
int x,y;
vector<int> G[N];
bool vis[N];
vector<int> ans;

void dfs(int cur,int end)
{
    if(cur == end)
    {
        for(auto& e : ans)
        {
            cout << e << " ";
        }
        exit(0);
    }
    for(int i = 0;i < G[cur].size();i++)
    {
        int next = G[cur][i];
        if(vis[next]) continue;
        vis[next] = true;
        ans.push_back(next);
        dfs(next,end);
        ans.pop_back();
        vis[next] = false;
    }
}

void solve()
{
    cin >> n >> x >> y;
    for(int i = 1;i <= n-1;i++)
    {
        int u,v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ans.push_back(x);
    vis[x] = true;
    dfs(x,y);

}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}